//
//  HLTshopinfogengduoViewController.m
//  huiliantong
//
//  Created by hlt on 15/10/22.
//  Copyright © 2015年 hlt. All rights reserved.
//

#import "HLTshopinfogengduoViewController.h"

@interface HLTshopinfogengduoViewController ()

@end

@implementation HLTshopinfogengduoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}




- (void) creatwebview:(NSString *)strurl
{
    
    
    NSString *content=  strurl;
        [self.mywebview loadHTMLString:content baseURL:[NSURL fileURLWithPath: [[NSBundle mainBundle]  bundlePath]]];
  self.mywebview.delegate=self;
    
}




- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    
    NSString *str=[NSString stringWithFormat:@"maxwidth=%f;",screen_width];
    
    NSString *sss=@"var script =document.createElement('script');"
    "script.type = 'text/javascript';"
    "script.text = \"function ResizeImages(){ "
    "var myimg,oldwidth,oldheight;"
    "var maxwidth=320;"
    "for(i=0;i<document.images.length;i++){"
    "myimg = document.images[i];"
    "if(myimg.width > maxwidth){"
    "myimg.width = maxwidth;"
    "}"
    "}"
    "}\";"
    "document.getElementsByTagName('head')[0].appendChild(script);";
    
    
    
    NSString *ss1=[sss  stringByReplacingOccurrencesOfString:@"maxwidth=320;" withString:str];
    
    [webView stringByEvaluatingJavaScriptFromString:
     
     ss1];
    
    [webView stringByEvaluatingJavaScriptFromString:@"ResizeImages();"];
    
    
    
    
    //字体大小
    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '100%'"];
    //字体颜色
    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor= 'black'"];
    //页面背景色
    //    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.background='#0C78C6'"];
    
    
    //NSInteger htmlHeight = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight"];
    
    //获取到webview当前的html，如果没有说明是初始化的那一次加载
    //    NSString *lHtml1 = [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.innerHTML"];
    //
    //    if (lHtml1) {
//    if (_biaozhi) {
//        
//        
//        
//        
//        
//        CGRect frame = webView.frame;
//        frame.size.height = 1;
//        webView.frame = frame;
//        
//        CGSize fittingSize = [webView sizeThatFits:CGSizeZero];
//        //        NSInteger ssa=fittingSize.height;
//        fittingSize.height=fittingSize.height+5;
//        _parent.height=fittingSize.height;
//        frame.size = fittingSize;
//        webView.frame = frame;
//        //刷新指定的section,显示优惠商户的部分
//        //        [_parent.rmdTableView reloadData];
//        
//        
//        //如果用针对性的刷新
//        NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:2];
//        [_parent.rmdTableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];
//        
//        _biaozhi=NO;
//    }
    
    
    
}

- (void)viewWillAppear:(BOOL)animated
{
    //打开导航
      self.navigationController.navigationBarHidden = NO;
    
}




@end
